<template>
  <dialog-editor ref="dialog"></dialog-editor>
</template>

<script>
import DialogEditor from '@/components/DialogEditor'
import dialogMixins from '@/utils/commonDialogMixins'

export default {
  mixins: [dialogMixins],
  components: {DialogEditor},
  data() {
    return {
      dataFormConfig: {
        id: {
          hidden: true
        },
        orderDetailId: {
          label: '订单编号',
          type: 'list',
          list: [],
          placeholder: '请输入订单'
        },
        productLeaveId: {
          label: '出库单号',
          type: 'list',
          list: [],
          placeholder: '请输入订单'
        },
        returnNumber: {
          label: '退货数量',
          type: 'number',
          max: 1000000,
          default: 0
        },
        returnTime: {
          label: '退货时间',
          type: 'date',
          placeholder: '请选择退货时间'
        },
        needBoxNumber: {
          label: '纸箱数量',
          type: 'number',
          max: 100000,
          default: 0
        },
        returnReason: {
          label: '退货原因',
          placeholder: '请输入退货原因'
        },
        remark: {
          label: '备注',
          inputType: 'textarea',
          placeholder: '请输入备注'
        },
        status: {
          label: '状态',
          type: 'switch',
          activeValue: 1,
          inactiveValue: 0,
          default: 1
        }
      },
      dataForm: {
        id: 0,
        orderDetailId: '',
        returnNumber: '',
        returnTime: '',
        needBoxNumber: '',
        returnReason: '',
        remark: '',
        status:1
      }
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0
      this.initOrderDetailList()

      this.$refs.dialog.initDialog({
        dataForm: this.dataForm,
        config: this.dataFormConfig,
        dataRule: this.getNeedDataRule('orderDetailId', 'returnNumber', 'returnTime', 'needBoxNumber', 'returnReason', 'remark','status'),
        initApi: 'orderApi/orderReturnInfo',
        saveApi: 'orderApi/saveOrderReturn',
        updateApi: 'orderApi/updateOrderReturn',
        objectName: 'orderReturn'
      })
    }
  }
}
</script>
